public class Length {
    protected final double value;
    protected final String unit;

    /**
     * 英尺
     */
    protected final String FOOT = "foot";

    /**
     * 码
     */
    protected final String YARD = "yard";

    /**
     * 英寸
     */
    protected final String INCH = "inch";


    public Length(double val, String unit) {
        this.value = val;
        this.unit = unit;
    }

    public Length as(String unit) {
        Length len = this;
        if (FOOT.equals(this.unit)) {
            return new Foot(this.value, unit).converter(unit);
        }

        if (YARD.equals(this.unit)) {
            return new Yard(this.value, unit).converter(unit);
        }

        if (INCH.equals(this.unit)) {
            return  new Inch(this.value,unit).converter(unit);
        }

        return len;
    }

    public double getVal() {
        return this.value;
    }

    public String getUinnt() {
        return this.unit;
    }

}
